Skip to content

Add menu to split Portenta flash #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

facchinm
Copy link
Member

This patchset allows splitting Portenta flash into different "partitions".
Unfortunately there's no method to keep M7 and M4 options synchronised, so it's up to the user not to flash binaries configured for different partitioning schemes.

The most interesting one is probably 100/0 , where the M4 firmware resides somewhere (not in internal flash) and must be copied to external RAM, address 0x60000000, before calling bootM4()

@janjongboom @iabdalkader @pnndra

@github-actions
Copy link

Memory usage change @ c348a49

Board flash % RAM for global variables %
arduino:mbed:envie_m4 🔺 0 - +24 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed:envie_m7 🔺 0 - +88 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board libraries/Scheduler/examples/MultipleBlinks
flash
% libraries/Scheduler/examples/MultipleBlinks
RAM for global variables
% libraries/doom/examples/Doom
flash
% libraries/doom/examples/Doom
RAM for global variables
% libraries/KernelDebug/examples/KernelDebug
flash
% libraries/KernelDebug/examples/KernelDebug
RAM for global variables
% libraries/Portenta_SDCARD/examples/TestSDCARD
flash
% libraries/Portenta_SDCARD/examples/TestSDCARD
RAM for global variables
% libraries/Portenta_Video/examples/Envie_video_coreboot
flash
% libraries/Portenta_Video/examples/Envie_video_coreboot
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
flash
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
flash
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
RAM for global variables
% libraries/ThreadDebug/examples/ThreadDebug
flash
% libraries/ThreadDebug/examples/ThreadDebug
RAM for global variables
% libraries/USBHOST/examples/KeyboardController
flash
% libraries/USBHOST/examples/KeyboardController
RAM for global variables
% libraries/USBHOST/examples/Shell
flash
% libraries/USBHOST/examples/Shell
RAM for global variables
% libraries/WiFi/examples/PortentaWiFiFirmwareUpdater
flash
% libraries/WiFi/examples/PortentaWiFiFirmwareUpdater
RAM for global variables
% libraries/PDM/examples/PDMSerialPlotter
flash
% libraries/PDM/examples/PDMSerialPlotter
RAM for global variables
%
arduino:mbed:envie_m4 0 0.0 0 0.0 24 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 24 0.0 0 0.0
arduino:mbed:envie_m7 0 0.0 0 0.0 24 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 88 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed:nano33ble 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,libraries/Scheduler/examples/MultipleBlinks<br>flash,%,libraries/Scheduler/examples/MultipleBlinks<br>RAM for global variables,%,libraries/doom/examples/Doom<br>flash,%,libraries/doom/examples/Doom<br>RAM for global variables,%,libraries/KernelDebug/examples/KernelDebug<br>flash,%,libraries/KernelDebug/examples/KernelDebug<br>RAM for global variables,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>flash,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>RAM for global variables,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>flash,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>flash,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>flash,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>RAM for global variables,%,libraries/ThreadDebug/examples/ThreadDebug<br>flash,%,libraries/ThreadDebug/examples/ThreadDebug<br>RAM for global variables,%,libraries/USBHOST/examples/KeyboardController<br>flash,%,libraries/USBHOST/examples/KeyboardController<br>RAM for global variables,%,libraries/USBHOST/examples/Shell<br>flash,%,libraries/USBHOST/examples/Shell<br>RAM for global variables,%,libraries/WiFi/examples/PortentaWiFiFirmwareUpdater<br>flash,%,libraries/WiFi/examples/PortentaWiFiFirmwareUpdater<br>RAM for global variables,%,libraries/PDM/examples/PDMSerialPlotter<br>flash,%,libraries/PDM/examples/PDMSerialPlotter<br>RAM for global variables,%
arduino:mbed:envie_m4,0,0.0,0,0.0,24,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,24,0.0,0,0.0
arduino:mbed:envie_m7,0,0.0,0,0.0,24,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,88,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed:nano33ble,0,0.0,0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,,,,,,,,,,,,,0,0.0,0,0.0

@hpssjellis
Copy link
Contributor

Any instructions on how to test this out @facchinm ?

I just want to run Blinky on the M4 and all the rest of the memory to the M7 to run an ML program and then run Blinky on the M7 and all the rest of the memory to the M4.

@iabdalkader
Copy link
Contributor

I just want to run Blinky on the M4 and all the rest of the memory to the M7 to run an ML program

I have very basic support for that in OpenMV firmware, it requires building the fw from source though, if you want to test it see: https://forums.openmv.io/t/portenta-micropython-on-m7-core-c-on-m4-core/6201/2?u=iabdalkader

@hpssjellis
Copy link
Contributor

I just want to run Blinky on the M4 and all the rest of the memory to the M7 to run an ML program

I have very basic support for that in OpenMV firmware, it requires building the fw from source though, if you want to test it see: https://forums.openmv.io/t/portenta-micropython-on-m7-core-c-on-m4-core/6201/2?u=iabdalkader

Thanks @iabdalkader , the instructions seem clear. I was however expecting C++ support for the old Arduino IDE, but from your post it looks like even when there is C++ support it will most likely involve building the C++ from source. Not against building from source, it just adds an extra level of complexity that I was hoping could be configured using an IDE. I think I will wait a bit and see what happens with this.

Anyone from Arduino care to comment?

* Relocate SDRAM at 0x60000000 to make it executable without touching the MPU
* Patch mbed-os-to-arduino to automatically patch the linker scripts
@facchinm facchinm force-pushed the portenta_flash_split branch from de8bc0f to bcc4583 Compare August 16, 2021 15:44
@facchinm
Copy link
Member Author

Hi Jeremy,
I rebased the patches over latest master and added a proper example (under RPC library).
To test this branch, the easiest way is to download the github-provided zip via https://github.com/facchinm/ArduinoCore-mbed/archive/refs/heads/portenta_flash_split.zip, and replace the files from mbed core 2.4.1 (the deprecated one).
After restarting the IDE you should get the extra menus.
Let me know if you need any help!

@github-actions
Copy link

Memory usage change @ bcc4583

Board flash % RAM for global variables %
arduino:mbed:envie_m7 🔺 0 - +64 0.0 - +0.01 0 - 0 0.0 - 0.0
arduino:mbed:nano33ble 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
arduino:mbed:nanorp2040connect 0 - 0 0.0 - 0.0 0 - 0 0.0 - 0.0
Click for full report table
Board libraries/Scheduler/examples/MultipleBlinks
flash
% libraries/Scheduler/examples/MultipleBlinks
RAM for global variables
% libraries/PDM/examples/PDMSerialPlotter
flash
% libraries/PDM/examples/PDMSerialPlotter
RAM for global variables
% libraries/doom/examples/Doom
flash
% libraries/doom/examples/Doom
RAM for global variables
% libraries/KernelDebug/examples/KernelDebug
flash
% libraries/KernelDebug/examples/KernelDebug
RAM for global variables
% libraries/Portenta_Camera/examples/CameraCaptureRawBytes
flash
% libraries/Portenta_Camera/examples/CameraCaptureRawBytes
RAM for global variables
% libraries/Portenta_Camera/examples/CameraMotionDetect
flash
% libraries/Portenta_Camera/examples/CameraMotionDetect
RAM for global variables
% libraries/Portenta_SDCARD/examples/TestSDCARD
flash
% libraries/Portenta_SDCARD/examples/TestSDCARD
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
flash
% libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo
RAM for global variables
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
flash
% libraries/Portenta_System/examples/PortentaH7_updateBootloader
RAM for global variables
% libraries/Portenta_Video/examples/Envie_video_coreboot
flash
% libraries/Portenta_Video/examples/Envie_video_coreboot
RAM for global variables
% libraries/RPC/examples/BootM4_from_SDRAM
flash
% libraries/RPC/examples/BootM4_from_SDRAM
RAM for global variables
% libraries/RPC/examples/RPC_m4
flash
% libraries/RPC/examples/RPC_m4
RAM for global variables
% libraries/RPC/examples/SerialPassthrough_RPC
flash
% libraries/RPC/examples/SerialPassthrough_RPC
RAM for global variables
% libraries/ThreadDebug/examples/ThreadDebug
flash
% libraries/ThreadDebug/examples/ThreadDebug
RAM for global variables
% libraries/USBHOST/examples/KeyboardController
flash
% libraries/USBHOST/examples/KeyboardController
RAM for global variables
% libraries/USBHOST/examples/Shell
flash
% libraries/USBHOST/examples/Shell
RAM for global variables
% libraries/WiFi/examples/PortentaWiFiFirmwareUpdater
flash
% libraries/WiFi/examples/PortentaWiFiFirmwareUpdater
RAM for global variables
% libraries/WiFi/examples/WiFiWebClient
flash
% libraries/WiFi/examples/WiFiWebClient
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/AP_SimpleWebServer
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/AP_SimpleWebServer
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectNoEncryption
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectNoEncryption
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWEP
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWEP
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA2Enterprise
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA2Enterprise
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworks
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworks
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworksAdvanced
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworksAdvanced
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/SimpleWebServerWiFi
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/SimpleWebServerWiFi
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/Tools/CheckFirmwareVersion
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/Tools/CheckFirmwareVersion
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/Tools/FirmwareUpdater
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/Tools/FirmwareUpdater
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/Tools/SerialNINAPassthrough
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/Tools/SerialNINAPassthrough
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiChatServer
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiChatServer
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiPing
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiPing
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiSSLClient
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiSSLClient
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiStorage
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiStorage
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpNtpClient
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpNtpClient
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpSendReceiveString
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpSendReceiveString
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClient
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClient
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClientRepeating
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClientRepeating
RAM for global variables
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebServer
flash
% /home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebServer
RAM for global variables
%
arduino:mbed:envie_m7 0 0.0 0 0.0 0 0.0 0 0.0 24 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 24 0.0 0 0.0 N/A N/A N/A N/A 64 0.01 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed:nano33ble 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
arduino:mbed:nanorp2040connect 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,libraries/Scheduler/examples/MultipleBlinks<br>flash,%,libraries/Scheduler/examples/MultipleBlinks<br>RAM for global variables,%,libraries/PDM/examples/PDMSerialPlotter<br>flash,%,libraries/PDM/examples/PDMSerialPlotter<br>RAM for global variables,%,libraries/doom/examples/Doom<br>flash,%,libraries/doom/examples/Doom<br>RAM for global variables,%,libraries/KernelDebug/examples/KernelDebug<br>flash,%,libraries/KernelDebug/examples/KernelDebug<br>RAM for global variables,%,libraries/Portenta_Camera/examples/CameraCaptureRawBytes<br>flash,%,libraries/Portenta_Camera/examples/CameraCaptureRawBytes<br>RAM for global variables,%,libraries/Portenta_Camera/examples/CameraMotionDetect<br>flash,%,libraries/Portenta_Camera/examples/CameraMotionDetect<br>RAM for global variables,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>flash,%,libraries/Portenta_SDCARD/examples/TestSDCARD<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>flash,%,libraries/Portenta_System/examples/PortentaH7_getBootloaderInfo<br>RAM for global variables,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>flash,%,libraries/Portenta_System/examples/PortentaH7_updateBootloader<br>RAM for global variables,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>flash,%,libraries/Portenta_Video/examples/Envie_video_coreboot<br>RAM for global variables,%,libraries/RPC/examples/BootM4_from_SDRAM<br>flash,%,libraries/RPC/examples/BootM4_from_SDRAM<br>RAM for global variables,%,libraries/RPC/examples/RPC_m4<br>flash,%,libraries/RPC/examples/RPC_m4<br>RAM for global variables,%,libraries/RPC/examples/SerialPassthrough_RPC<br>flash,%,libraries/RPC/examples/SerialPassthrough_RPC<br>RAM for global variables,%,libraries/ThreadDebug/examples/ThreadDebug<br>flash,%,libraries/ThreadDebug/examples/ThreadDebug<br>RAM for global variables,%,libraries/USBHOST/examples/KeyboardController<br>flash,%,libraries/USBHOST/examples/KeyboardController<br>RAM for global variables,%,libraries/USBHOST/examples/Shell<br>flash,%,libraries/USBHOST/examples/Shell<br>RAM for global variables,%,libraries/WiFi/examples/PortentaWiFiFirmwareUpdater<br>flash,%,libraries/WiFi/examples/PortentaWiFiFirmwareUpdater<br>RAM for global variables,%,libraries/WiFi/examples/WiFiWebClient<br>flash,%,libraries/WiFi/examples/WiFiWebClient<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/AP_SimpleWebServer<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/AP_SimpleWebServer<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectNoEncryption<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectNoEncryption<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWEP<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWEP<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA2Enterprise<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ConnectWithWPA2Enterprise<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworks<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworks<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworksAdvanced<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/ScanNetworksAdvanced<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/SimpleWebServerWiFi<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/SimpleWebServerWiFi<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/Tools/CheckFirmwareVersion<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/Tools/CheckFirmwareVersion<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/Tools/FirmwareUpdater<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/Tools/FirmwareUpdater<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/Tools/SerialNINAPassthrough<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/Tools/SerialNINAPassthrough<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiChatServer<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiChatServer<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiPing<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiPing<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiSSLClient<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiSSLClient<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiStorage<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiStorage<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpNtpClient<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpNtpClient<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpSendReceiveString<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiUdpSendReceiveString<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClient<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClient<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClientRepeating<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebClientRepeating<br>RAM for global variables,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebServer<br>flash,%,/home/runner/Arduino/libraries/WiFiNINA/examples/WiFiWebServer<br>RAM for global variables,%
arduino:mbed:envie_m7,0,0.0,0,0.0,0,0.0,0,0.0,24,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,24,0.0,0,0.0,N/A,N/A,N/A,N/A,64,0.01,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0
arduino:mbed:nano33ble,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,,,,,,,,,,,,,,,,
arduino:mbed:nanorp2040connect,0,0.0,0,0.0,0,0.0,0,0.0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0

@hpssjellis
Copy link
Contributor

Hi Jeremy,
I rebased the patches over latest master and added a proper example (under RPC library).
To test this branch, the easiest way is to download the github-provided zip via https://github.com/facchinm/ArduinoCore-mbed/archive/refs/heads/portenta_flash_split.zip, and replace the files from mbed core 2.4.1 (the deprecated one).
After restarting the IDE you should get the extra menus.
Let me know if you need any help!

@facchinm The install went fine, I see the extra RPC example BootM4_from_SDRAM.ino

Does this example just boot M4 to the SD Card or does it also re format the M7 memory to grab all the M4 memory? If it does reformat memory I don't see the relevant code. I just want to tweak the M7 and M4 memory not completely move the M4 to an SD card.

P.S. Great work so far.

Here is the example BootM4_from_SDRAM.ino

#include "SDRAM.h"
#include "QSPIFBlockDevice.h"
#include "MBRBlockDevice.h"
#include "FATFileSystem.h"
#include "PluggableUSBMSD.h"

QSPIFBlockDevice root(PD_11, PD_12, PF_7, PD_13,  PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
mbed::MBRBlockDevice ota_data(&root, 2);
mbed::FATFileSystem ota_data_fs("fs");

void USBMSD::begin()
{
}

USBMSD MassStorage(&root);

long getFileSize(FILE *fp) {
  fseek(fp, 0, SEEK_END);
  int size = ftell(fp);
  fseek(fp, 0, SEEK_SET);

  return size;
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  while (!Serial);

  SDRAM.begin(0);

  int err = ota_data_fs.mount(&ota_data);
  if (err) {
    Serial.println("Please run PortentaWiFiFirmwareUpdater once");
    while (1) {
      delay(10000);
    }
  }

  // Copy M4 firmware to SDRAM
  FILE* fw = fopen("/fs/fw.bin", "r");
  if (fw == NULL) {
    Serial.println("Please copy a firmware for M4 core in the PORTENTA mass storage");
    Serial.println("When done, please unmount the mass storage and reset the board");
    MassStorage.begin();
    while (1) {
      delay(10000);
    }
  }
  fread((uint8_t*)CM4_BINARY_START, getFileSize(fw), 1, fw);
  fclose(fw);

  bootM4();
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(10000);
}

@facchinm
Copy link
Member Author

@hpssjellis the example shows how to perform the most "difficult" option, 100/0 split, that needs some extra steps to copy the M4 code into external SDRAM.
If you just want to tune the flash in different ways, take a look at 75/25 split that doesn't need any extra operation, just selecting the same menu entry for both M7 and M4 and then calling bootM4() should do the trick

@hpssjellis
Copy link
Contributor

@hpssjellis the example shows how to perform the most "difficult" option, 100/0 split, that needs some extra steps to copy the M4 code into external SDRAM.
If you just want to tune the flash in different ways, take a look at 75/25 split that doesn't need any extra operation, just selecting the same menu entry for both M7 and M4 and then calling bootM4() should do the trick

I didnt understand until I saw the new menu item.
20210817_012414

That is super easy, and truly amazing, especially the 100/0, but I am looking for finer control, instead of just:

50/50 (M7/M4)
75/25
100/0

Any chance you could add:
25/75
40/60
60/40
90/10

Or can this be done from source with whatever settings are wanted.

My use case is where one core just needs a bit more memory and the other core doesnt need as much.

@hpssjellis
Copy link
Contributor

@facchinm

Just some feedback: In the regular Arduino IDE 1.8.15 when switching from M7 to M4 the "Flash Split" menu resets to 1Mb M7 + 1Mb M4 which is more than a little irritating.

What does seem to make sense is that I have been flashing my M7 program without bootM4(); activated, with whatever Flash Split I want, then flashing M4 with the same Flash Split, then flashing M7 with the bootM4(); function activated. So that M4 is never called before it is properly programmed.

When testing 1:1 or 75/25 (so know added complexity with booting from an SD card)
I am finding: That M4 compiles fine, M7 compiles and works fine, but M4 is having trouble booting, I get flashing red from M4, while M7 is running fine.

Is anyone else having similar issues?

P.S. Possibly my installation is a bit messed up, it took a few trys to get it working.

P.S.S I thought M7 had a smaller flash setting anyway, since I find I can load a much larger machine learning model onto the M4 core than the M7 core. I don't really understand the setting 1Mb M7 + 1Mb M4 since I think M4 has more flash by default than M7. Any clarification here.

The folloswing image is some tests I did a while ago loading a much larger program onto the M4

crashTest04

@hpssjellis
Copy link
Contributor

@facchinm

Should I continue testing this Martino or wait for the next version?

@hpssjellis
Copy link
Contributor

@facchinm, Any updates with the split Portenta Flash?

I am having a lot of fun with Edge Impulse loading larger Machine Learning resolution models than the regular 96x96 (ignore the skew as the OLED is 128x64), seen here as the small rectangle showing only part of the 320x240 screen.
image

..

These models identify if the Portenta is viewing a microcontroller. The LED turns blue when it "sees" a microcontroller, and green if not.
This one is 224x224 as can be seen by the larger rectangle on screen.

image

..

When the split flash is fully working I should be able to get some much larger models loaded. Presently the split flash seems to load fine, I just can't load any larger models almost as if the larger memory is not being fully allocated.

@facchinm
Copy link
Member Author

Manually merged

@facchinm facchinm closed this Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants